package com.xgs.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xgs.com.atguigu.model.system.SysRole;
import com.xgs.mappers.RoleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/test")
@RestController
public class TestController {

    @Autowired
    private RoleMapper roleMapper;

    @GetMapping("query")
    public List<SysRole> queryAll() {
        List<SysRole> sysRoles = roleMapper.selectList(null);
        return sysRoles;
    }
    @GetMapping("queryByid")
    public List<SysRole> queryById(String name) {
        QueryWrapper<SysRole> queryWrapper = new QueryWrapper<>();
        QueryWrapper<SysRole> eq = queryWrapper.eq("role_name", "系统管理员");
        List<SysRole> sysRoles = roleMapper.selectList(eq);
        for (SysRole sysRole : sysRoles) {
            System.out.println(sysRole);
        }
        return sysRoles;
    }
}
